package text;

import enums.Signal;

import java.util.*;

/**
 * Created by butterfly on 2018/5/24.
 */
public class EnumTest {


    public static void main(String[] args) {
        for (Signal signal : Signal.values()) {
            System.out.println(signal);
        }
        //比较枚举实例先后顺序
        int i = Signal.yellow.compareTo(Signal.greeen);
        System.out.println(i);
        //返回枚举实例名称
        String name = Signal.yellow.name();
        String s = Signal.yellow.toString();
        //返回枚举实例的索引
        int ordinal = Signal.yellow.ordinal();
        //枚举枚举实例返回枚举类型
        Signal yellow = Signal.valueOf("yellow");
        System.out.println(yellow);//直接打印枚举等于输出枚举的名字

        PriorityQueue<Object> objects = new PriorityQueue<>();
        objects.offer(8);
        objects.offer(-3);
        objects.offer(9);
        objects.offer(0);
        System.out.println(objects);

        Map map = new HashMap();
        map.put("123","asdfadsf");
        map.put("222","xxxxxx");
        map.put("222","222");

        Set set = map.entrySet();//返回key-value组成的Set集合
        System.out.println(set.toString());
        //hashmap认为元素equals返回true且hashcode相同，则认为是同一个key
        Map map2 = new HashMap();
        map2.put(new String("1"),"123");
        map2.put(new String("1"),"333");
        System.out.println(map2.toString());
        //Collections工具类创建线程安全的集合
        List list = Collections.synchronizedList(new ArrayList());
        
    }
}
